package com.dps.recommend.layer.rank;

import com.dps.recommend.ann.LayerAnn;
import com.dps.recommend.beans.DpsRequest;
import com.dps.recommend.beans.ProcessInterface;
import com.dps.recommend.beans.RecItemDps;
import com.dps.recommend.enums.LayerEnum;
import com.dps.recommend.utils.DpsBaseService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 分页数量
 */
@Service
@LayerAnn(layer = LayerEnum.RANK)
class DpsPageNumRank extends DpsBaseService implements ProcessInterface {

    @Override
    public <R extends RecItemDps> List doProcess(DpsRequest dpsRequest, List<R> list) {
        int skipNum = (dpsRequest.getRequest().getPageNum() - 1) * dpsRequest.getRequest().getPageSize();
        List<R> recItemRes = list.stream().skip(skipNum).limit(dpsRequest.getRequest().getPageSize()).collect(Collectors.toList());
        return recItemRes;
    }
}
